package com.lwbpro.system.mapper;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lwbpro.system.domain.StudentManage;

/**
 * 学生管理Mapper接口
 *
 * @author achievement
 * @date 2024-08-28
 */
public interface StudentManageMapper extends BaseMapper<StudentManage> {
    /**
     * 查询学生管理
     *
     * @param id 学生管理主键
     * @return 学生管理
     */
    public StudentManage selectStudentManageById(Long id);

    /**
     * 查询学生管理列表
     *
     * @param studentManage 学生管理
     * @return 学生管理集合
     */
    public List<StudentManage> selectStudentManageList(StudentManage studentManage);

    /**
     * 新增学生管理
     *
     * @param studentManage 学生管理
     * @return 结果
     */
    public int insertStudentManage(StudentManage studentManage);

    /**
     * 修改学生管理
     *
     * @param studentManage 学生管理
     * @return 结果
     */
    public int updateStudentManage(StudentManage studentManage);

    /**
     * 删除学生管理
     *
     * @param id 学生管理主键
     * @return 结果
     */
    public int deleteStudentManageById(Long id);

    /**
     * 批量删除学生管理
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteStudentManageByIds(Long[] ids);

    default List<StudentManage> selectByNames(List<String> studentNames) {
        LambdaQueryWrapper<StudentManage> lqw = new LambdaQueryWrapper<>();
        lqw.in(StudentManage::getStudentName, studentNames);
        return selectList(lqw);
    }

    default StudentManage checkName(StudentManage studentManage) {
        LambdaQueryWrapper<StudentManage> lqw = new LambdaQueryWrapper<>();
        if (studentManage.getId() != null) {
            lqw.ne(StudentManage::getId, studentManage.getId());
        }
        lqw.eq(StudentManage::getStudentName, studentManage.getStudentName());
        lqw.last("limit 1");
        return selectOne(lqw);
    }
}
